package cn.seocoo.platform.api.controller.pay;


import cn.seocoo.platform.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;


/**
 * 查询支付结果（本地查询）
 *
 * @author duanpj
 * @date: 2019/12/16 21:03
 */
@RestController
@RequestMapping("/api/payOperate")
public class PayNotifyController {

    private static final Logger logger = LoggerFactory.getLogger(PayNotifyController.class);



    @PostMapping("/payResult")
    public Map payResult(@RequestBody ModelMap modelMap)  {
        Map map = new HashMap<>();
        if (StringUtils.isNull(modelMap.get("orderNumber")) || StringUtils.isEmpty(modelMap.get("orderNumber").toString())) {
            map.put("error","orderNumber不能为空");
        }
        if (StringUtils.isNull(modelMap.get("orderType")) || StringUtils.isEmpty(modelMap.get("orderType").toString())) {
            map.put("error","orderType不能为空");
        }
        String orderNo = modelMap.get("orderNumber").toString();
        String orderType = modelMap.get("orderType").toString();
        int state = 1;
        if("2".equals(orderType)){
            logger.warn("------------------->查询 诚意金 支付结果<-------------------------");
           // state = iProjectInfoService.selectProIsPay(orderNo);
        }else if("3".equals(orderType)){
            logger.warn("------------------->查询 投标 支付结果<-------------------------");
           // state = iProwinRelationService.selectProWinIsPay(orderNo);
        }else if("4".equals(orderType)){
            logger.warn("------------------->查询 设计稿 支付结果<-------------------------");

        }
        if(state == 1){
            //支付失败
            map.put("state","false");
        }else if(state == 0){
            //支付成功
            map.put("state","true");
        }
        return map;
    }





}
